package com.example.hcbmsm.controller;

import com.example.hcbmsm.domain.Dept;
import com.example.hcbmsm.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/10/29 22:47
 */
@RestController
@CrossOrigin
@RequestMapping("/dept")
public class DeptController {
    @Autowired
    private DeptService deptService;
    @GetMapping("/allDept")
    public Map findAllDept(){
        return deptService.findAllDept();
    }

    @GetMapping("/list")
    public Map list(String deptName, int page, int limit){
        return deptService.list(deptName, page, limit);
    }

    @PostMapping("/add")
    public Map add(@RequestBody Dept dept){
        return deptService.add(dept);
    }

    @PostMapping("/renew")
    public Map renew(@RequestBody Dept dept){
        return deptService.renew(dept);
    }

    @PostMapping("/remove")
    public Map remove(Long deptId){
        return deptService.remove(deptId);
    }

}
